Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@oclif/parser

Package Overview
Dependencies
Maintainers
7
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oclif/parser

arg and flag parser for oclif

  • 3.8.17
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
597K
decreased by-7.93%
Maintainers
7
Weekly downloads
 
Created

What is @oclif/parser?

@oclif/parser is a command-line argument parser designed for use with the Oclif framework. It helps in parsing command-line arguments, flags, and options in a structured and efficient manner.

What are @oclif/parser's main functionalities?

Parsing Arguments

This feature allows you to parse positional arguments from the command line. The code sample demonstrates how to define and parse two positional arguments.

const { parse } = require('@oclif/parser');
const argv = ['arg1', 'arg2'];
const options = { args: [{ name: 'firstArg' }, { name: 'secondArg' }] };
const result = parse(argv, options);
console.log(result.args); // { firstArg: 'arg1', secondArg: 'arg2' }

Parsing Flags

This feature allows you to parse flags from the command line. The code sample demonstrates how to define and parse two string flags.

const { parse } = require('@oclif/parser');
const argv = ['--flag1', 'value1', '--flag2', 'value2'];
const options = { flags: { flag1: { type: 'string' }, flag2: { type: 'string' } } };
const result = parse(argv, options);
console.log(result.flags); // { flag1: 'value1', flag2: 'value2' }

Parsing Boolean Flags

This feature allows you to parse boolean flags from the command line. The code sample demonstrates how to define and parse two boolean flags.

const { parse } = require('@oclif/parser');
const argv = ['--flag1', '--no-flag2'];
const options = { flags: { flag1: { type: 'boolean' }, flag2: { type: 'boolean' } } };
const result = parse(argv, options);
console.log(result.flags); // { flag1: true, flag2: false }

Parsing Options with Default Values

This feature allows you to define default values for flags. The code sample demonstrates how to set and retrieve a default value for a flag.

const { parse } = require('@oclif/parser');
const argv = [];
const options = { flags: { flag1: { type: 'string', default: 'defaultValue' } } };
const result = parse(argv, options);
console.log(result.flags); // { flag1: 'defaultValue' }

Other packages similar to @oclif/parser

Keywords

FAQs

Package last updated on 19 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc